package com.ocom.payconfig.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.card.EntityKitchenPrtInfo;
import com.ocom.common.request.payconfig.KitchenPrinter.dto.KitchenPrtListDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoKitchenPrtInfo extends BaseMapper<EntityKitchenPrtInfo> {

    @Select({"<script>",
            "SELECT\n" +
                    "\tP.*, S.*\n" +
                    "FROM\n" +
                    "\tkitchen_prt_info P\n" +
                    "LEFT JOIN kitchen_prt_scheme S ON S.k_prt_id = P.prt_id\n" +
                    "WHERE\n" +
                    "\tP.com_id = #{comId}\n" +
                    " <when test=\"restId != null and restId &gt; 0 \"> " +
                    "AND P.rest_id = #{restId}\n" +
                    "</when>" +
                    " <when test=\"prtId != null and prtId &gt; 0 \"> " +
                    "AND P.prt_id = #{prtId}\n" +
                    "</when>" +
                    "ORDER BY\n" +
                    "\tprt_sn" +
                    "</script>"})
    public List<KitchenPrtListDto> kitchenPrtList(@Param("comId") Long comId, @Param("restId")Long restId, @Param("prtId")Long prtId);


    @Select({"<script>",
            "SELECT\n" +
                    "\tP.*, S.* , po.point_id \n" +
                    "FROM\n" +
                    "\tkitchen_prt_info P\n" +
                    "LEFT JOIN kitchen_prt_scheme S ON S.k_prt_id = P.prt_id\n" +
                    "LEFT JOIN point_config po ON po.rest_id = P.rest_id \n" +
                    "WHERE\n" +
                    " S.if_order_sum  = 1 \n" +
                    " AND P.product  =  #{product} \n" +
                    "</script>"})
    public List<KitchenPrtListDto> kitchenPrtList2(@Param("product") Integer product);


}
